package demo;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: rei
 * Date: 2025-11-26
 * Time: 17:51
 */
public class FileWriter_test {
    public static void main(String[] args) throws IOException {
        File file = new File("c:/temp/123.txt");
        //创建一个字符流
        FileWriter fileWriter = new FileWriter(file);
        //写
        fileWriter.write("hello world");
        fileWriter.write("\n");
        fileWriter.write("你好世界!!!");
        fileWriter.write("\n");
        fileWriter.write("小然大笨蛋");
        //刷新
        fileWriter.flush();
        //关闭流
        fileWriter.close();
    }
}
